package com.ruoyi.imports.domain;

import com.alibaba.excel.annotation.format.DateTimeFormat;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.ruoyi.imports.anno.ExcelColumn;
import com.ruoyi.imports.anno.ExcelSheet;
import lombok.Data;

import java.io.Serializable;
import java.math.BigDecimal;

@Data
@ExcelSheet("过程数据监测表")
public class ProcessExcelData implements Serializable {
    private static final long serialVersionUID = 1L;
    // ======================== 主表核心字段（最终出水 + 基础信息） ========================
    @ExcelColumn(header = {"日期"}, order = 0, required = true)
    @DateTimeFormat("yyyy年MM月dd日")
    @ColumnWidth(15)
    private String date;

    @ExcelColumn(header = {"时间"}, order = 1, required = true)
    @DateTimeFormat("HH:mm")
    @ColumnWidth(10)
    private String time;

    // ======================== 从表字段（各处理单元过程数据） ========================
    // ---------- COD(mg/L) 各处理单元 ----------
    @ExcelColumn(header = {"COD(mg/L)", "调节池"}, order = 2)
    @ColumnWidth(12)
    private BigDecimal codRegulatingPool;

    @ExcelColumn(header = {"COD(mg/L)", "预曝器"}, order = 3)
    @ColumnWidth(12)
    private BigDecimal codPreExposure;

    @ExcelColumn(header = {"COD(mg/L)", "初沉池"}, order = 4)
    @ColumnWidth(12)
    private BigDecimal codPrimarySettlingTank;

    @ExcelColumn(header = {"COD(mg/L)", "厌氧池","A系"}, order = 5)
    @ColumnWidth(12)
    private BigDecimal codAnaerobicTankA;

    @ExcelColumn(header = {"COD(mg/L)", "厌氧池","B系"}, order = 6)
    @ColumnWidth(12)
    private BigDecimal codAnaerobicTankB;

    @ExcelColumn(header = {"COD(mg/L)", "一级缺氧池","A系"}, order = 7)
    @ColumnWidth(12)
    private BigDecimal codAnoxicTankOneA;

    @ExcelColumn(header = {"COD(mg/L)", "一级缺氧池","B系"}, order = 8)
    @ColumnWidth(12)
    private BigDecimal codAnoxicTankOneB;

    @ExcelColumn(header = {"COD(mg/L)", "一级好氧池","A系"}, order = 9)
    @ColumnWidth(12)
    private BigDecimal codAerobicTankOneA;

    @ExcelColumn(header = {"COD(mg/L)", "一级好氧池","B系"}, order = 10)
    @ColumnWidth(12)
    private BigDecimal codAerobicTankOneB;

    @ExcelColumn(header = {"COD(mg/L)", "二级缺氧池","A系"}, order = 11)
    @ColumnWidth(12)
    private BigDecimal codAnoxicTankTwoA;

    @ExcelColumn(header = {"COD(mg/L)", "二级缺氧池","B系"}, order = 12)
    @ColumnWidth(12)
    private BigDecimal codAnoxicTankTwoB;

    @ExcelColumn(header = {"COD(mg/L)", "二级好氧池","A系"}, order = 13)
    @ColumnWidth(12)
    private BigDecimal codAerobicTankTwoA;

    @ExcelColumn(header = {"COD(mg/L)", "二级好氧池","B系"}, order = 14)
    @ColumnWidth(12)
    private BigDecimal codAerobicTankTwoB;

    @ExcelColumn(header = {"COD(mg/L)", "二沉池","A系"}, order = 15)
    @ColumnWidth(12)
    private BigDecimal codSstOneA;

    @ExcelColumn(header = {"COD(mg/L)", "二沉池","B系"}, order = 16)
    @ColumnWidth(12)
    private BigDecimal codSstOneB;

    @ExcelColumn(header = {"COD(mg/L)", "混凝池"}, order = 17)
    @ColumnWidth(12)
    private BigDecimal codCoagulationTank;

    // ---------- 氨氮(mg/L) 各处理单元 ----------
    @ExcelColumn(header = {"氨氮(mg/L)", "调节池"}, order = 18)
    @ColumnWidth(12)
    private BigDecimal nh3nRegulatingPool;

    @ExcelColumn(header = {"氨氮(mg/L)", "预曝器"}, order = 19)
    @ColumnWidth(12)
    private BigDecimal nh3nPreExposure;

    @ExcelColumn(header = {"氨氮(mg/L)", "初沉池"}, order = 20)
    @ColumnWidth(12)
    private BigDecimal nh3nPrimarySettlingTank;

    @ExcelColumn(header = {"氨氮(mg/L)", "厌氧池","A系"}, order = 21)
    @ColumnWidth(12)
    private BigDecimal nh3nAnaerobicTankA;

    @ExcelColumn(header = {"氨氮(mg/L)", "厌氧池","B系"}, order = 22)
    @ColumnWidth(12)
    private BigDecimal nh3nAnaerobicTankB;

    @ExcelColumn(header = {"氨氮(mg/L)", "一级缺氧池","A系"}, order = 23)
    @ColumnWidth(12)
    private BigDecimal nh3nAnoxicTankOneA;

    @ExcelColumn(header = {"氨氮(mg/L)", "一级缺氧池","B系"}, order = 24)
    @ColumnWidth(12)
    private BigDecimal nh3nAnoxicTankOneB;

    @ExcelColumn(header = {"氨氮(mg/L)", "一级好氧池","A系"}, order = 25)
    @ColumnWidth(12)
    private BigDecimal nh3nAerobicTankOneA;

    @ExcelColumn(header = {"氨氮(mg/L)", "一级好氧池","B系"}, order = 26)
    @ColumnWidth(12)
    private BigDecimal nh3nAerobicTankOneB;

    @ExcelColumn(header = {"氨氮(mg/L)", "二级缺氧池","A系"}, order = 27)
    @ColumnWidth(12)
    private BigDecimal nh3nAnoxicTankTwoA;

    @ExcelColumn(header = {"氨氮(mg/L)", "二级缺氧池","B系"}, order = 28)
    @ColumnWidth(12)
    private BigDecimal nh3nAnoxicTankTwoB;

    @ExcelColumn(header = {"氨氮(mg/L)", "二级好氧池","A系"}, order = 29)
    @ColumnWidth(12)
    private BigDecimal nh3nAerobicTankTwoA;

    @ExcelColumn(header = {"氨氮(mg/L)", "二级好氧池","B系"}, order = 30)
    @ColumnWidth(12)
    private BigDecimal nh3nAerobicTankTwoB;

    @ExcelColumn(header = {"氨氮(mg/L)", "二沉池","A系"}, order = 31)
    @ColumnWidth(12)
    private BigDecimal nh3nSstOneA;

    @ExcelColumn(header = {"氨氮(mg/L)", "二沉池","B系"}, order = 32)
    @ColumnWidth(12)
    private BigDecimal nh3nSstOneB;


    @ExcelColumn(header = {"氨氮(mg/L)", "混凝池"}, order = 33)
    @ColumnWidth(12)
    private BigDecimal nh3nCoagulationTank;

    // ---------- 硫氰酸根(mg/L) 各处理单元 ----------

    @ExcelColumn(header = {"硫氰酸根(mg/L)", "调节池"}, order = 34)
    @ColumnWidth(12)
    private BigDecimal scnRegulatingPool;

    @ExcelColumn(header = {"硫氰酸根(mg/L)", "预曝器"}, order = 35)
    @ColumnWidth(12)
    private BigDecimal scnPreExposure;

    @ExcelColumn(header = {"硫氰酸根(mg/L)", "初沉池"}, order = 36)
    @ColumnWidth(12)
    private BigDecimal scnPrimarySettlingTank;

    @ExcelColumn(header = {"硫氰酸根(mg/L)", "厌氧池","A系"}, order = 37)
    @ColumnWidth(12)
    private BigDecimal scnAnaerobicTankA;

    @ExcelColumn(header = {"硫氰酸根(mg/L)", "厌氧池","B系"}, order = 38)
    @ColumnWidth(12)
    private BigDecimal scnAnaerobicTankB;

    @ExcelColumn(header = {"硫氰酸根(mg/L)", "一级缺氧池","A系"}, order = 39)
    @ColumnWidth(12)
    private BigDecimal scnAnoxicTankOneA;

    @ExcelColumn(header = {"硫氰酸根(mg/L)", "一级缺氧池","B系"}, order = 40)
    @ColumnWidth(12)
    private BigDecimal scnAnoxicTankOneB;

    @ExcelColumn(header = {"硫氰酸根(mg/L)", "一级好氧池","A系"}, order = 41)
    @ColumnWidth(12)
    private BigDecimal scnAerobicTankOneA;

    @ExcelColumn(header = {"硫氰酸根(mg/L)", "一级好氧池","B系"}, order = 42)
    @ColumnWidth(12)
    private BigDecimal scnAerobicTankOneB;

    @ExcelColumn(header = {"硫氰酸根(mg/L)", "二级缺氧池","A系"}, order = 43)
    @ColumnWidth(12)
    private BigDecimal scnAnoxicTankTwoA;

    @ExcelColumn(header = {"硫氰酸根(mg/L)", "二级缺氧池","B系"}, order = 44)
    @ColumnWidth(12)
    private BigDecimal scnAnoxicTankTwoB;

    @ExcelColumn(header = {"硫氰酸根(mg/L)", "二级好氧池","A系"}, order = 45)
    @ColumnWidth(12)
    private BigDecimal scnAerobicTankTwoA;

    @ExcelColumn(header = {"硫氰酸根(mg/L)", "二级好氧池","B系"}, order = 46)
    @ColumnWidth(12)
    private BigDecimal scnAerobicTankTwoB;

    @ExcelColumn(header = {"硫氰酸根(mg/L)", "二沉池","A系"}, order = 47)
    @ColumnWidth(12)
    private BigDecimal scnSstOneA;

    @ExcelColumn(header = {"硫氰酸根(mg/L)", "二沉池","B系"}, order = 48)
    @ColumnWidth(12)
    private BigDecimal scnSstOneB;

    @ExcelColumn(header = {"硫氰酸根(mg/L)", "混凝池"}, order = 49)
    @ColumnWidth(12)
    private BigDecimal scnCoagulationTank;

    @ExcelColumn(header = {"PH", "调节池"}, order = 50)
    @ColumnWidth(12)
    private BigDecimal phRegulatingPool;

    @ExcelColumn(header = {"PH", "预曝器"}, order = 51)
    @ColumnWidth(12)
    private BigDecimal phPreExposure;

    @ExcelColumn(header = {"PH", "初沉池"}, order = 52)
    @ColumnWidth(12)
    private BigDecimal phPrimarySettlingTank;

    @ExcelColumn(header = {"PH", "厌氧池","A系"}, order = 53)
    @ColumnWidth(12)
    private BigDecimal phAnaerobicTankA;

    @ExcelColumn(header = {"PH", "厌氧池","B系"}, order = 54)
    @ColumnWidth(12)
    private BigDecimal phAnaerobicTankB;

    @ExcelColumn(header = {"PH", "一级缺氧池","A系"}, order = 55)
    @ColumnWidth(12)
    private BigDecimal phAnoxicTankOneA;

    @ExcelColumn(header = {"PH", "一级缺氧池","B系"}, order = 56)
    @ColumnWidth(12)
    private BigDecimal phAnoxicTankOneB;

    @ExcelColumn(header = {"PH", "一级好氧池","A系"}, order = 57)
    @ColumnWidth(12)
    private BigDecimal phAerobicTankOneA;

    @ExcelColumn(header = {"PH", "一级好氧池","B系"}, order = 58)
    @ColumnWidth(12)
    private BigDecimal phAerobicTankOneB;

    @ExcelColumn(header = {"PH", "二级缺氧池","A系"}, order = 59)
    @ColumnWidth(12)
    private BigDecimal phAnoxicTankTwoA;

    @ExcelColumn(header = {"PH", "二级缺氧池","B系"}, order = 60)
    @ColumnWidth(12)
    private BigDecimal phAnoxicTankTwoB;

    @ExcelColumn(header = {"PH", "二级好氧池","A系"}, order = 61)
    @ColumnWidth(12)
    private BigDecimal phAerobicTankTwoA;

    @ExcelColumn(header = {"PH", "二级好氧池","B系"}, order = 62)
    @ColumnWidth(12)
    private BigDecimal phAerobicTankTwoB;

    @ExcelColumn(header = {"PH", "二沉池","A系"}, order = 63)
    @ColumnWidth(12)
    private BigDecimal phSstOneA;

    @ExcelColumn(header = {"PH", "二沉池","A系"}, order = 64)
    @ColumnWidth(12)
    private BigDecimal phSstOneB;

    @ExcelColumn(header = {"PH", "混凝池"}, order = 65)
    @ColumnWidth(12)
    private BigDecimal phCoagulationTank;
    // ======================== 扩展：其他指标（如 PH、硫化物等）可继续补充 ========================

    // ======================== 从表字段（亚硝酸盐指标各处理单元数据） ========================
    // 亚硝酸盐 - 一级二沉池A系
    @ExcelColumn(header = {"亚硝酸盐(mg/L)", "一级二沉池", "A系"}, order = 66)
    @ColumnWidth(12)
    private BigDecimal nitritePrimarySstA;

    // 亚硝酸盐 - 一级二沉池B系
    @ExcelColumn(header = {"亚硝酸盐(mg/L)", "一级二沉池", "B系"}, order = 67)
    @ColumnWidth(12)
    private BigDecimal nitritePrimarySstB;

    // 亚硝酸盐 - 二级二沉池A系
    @ExcelColumn(header = {"亚硝酸盐(mg/L)", "二级二沉池", "A系"}, order = 68)
    @ColumnWidth(12)
    private BigDecimal nitriteSecondarySstA;

    // 亚硝酸盐 - 二级二沉池B系
    @ExcelColumn(header = {"亚硝酸盐(mg/L)", "二级二沉池", "B系"}, order = 69)
    @ColumnWidth(12)
    private BigDecimal nitriteSecondarySstB;

    // ======================== 从表字段（硝酸盐指标各处理单元数据） ========================
    // 硝酸盐 - 一级二沉池A系
    @ExcelColumn(header = {"硝酸盐(mg/L)", "一级二沉池", "A系"}, order = 70)
    @ColumnWidth(12)
    private BigDecimal nitratePrimarySstA;

    // 硝酸盐 - 一级二沉池B系
    @ExcelColumn(header = {"硝酸盐(mg/L)", "一级二沉池", "B系"}, order = 71)
    @ColumnWidth(12)
    private BigDecimal nitratePrimarySstB;

    // 硝酸盐 - 二级二沉池A系
    @ExcelColumn(header = {"硝酸盐(mg/L)", "二级二沉池", "A系"}, order = 72)
    @ColumnWidth(12)
    private BigDecimal nitrateSecondarySstA;

    // 硝酸盐 - 二级二沉池B系
    @ExcelColumn(header = {"硝酸盐(mg/L)", "二级二沉池", "B系"}, order = 73)
    @ColumnWidth(12)
    private BigDecimal nitrateSecondarySstB;

    // ======================== 从表字段（总磷指标各处理单元数据） ========================
    // 总磷 - A二沉池（推测为一级二沉池A系）
    @ExcelColumn(header = {"总磷(mg/L)", "A二沉"}, order = 74)
    @ColumnWidth(12)
    private BigDecimal tpSstA;

    // 总磷 - B二沉池（推测为一级二沉池B系）
    @ExcelColumn(header = {"总磷(mg/L)", "B二沉"}, order = 75)
    @ColumnWidth(12)
    private BigDecimal tpSstB;

    // ======================== 从表字段（总氰指标各处理单元数据） ========================
    // 总氰 - A二沉池
    @ExcelColumn(header = {"总氰(mg/L)", "A二沉"}, order = 76)
    @ColumnWidth(12)
    private BigDecimal totalCyanideSstA;

    // 总氰 - B二沉池
    @ExcelColumn(header = {"总氰(mg/L)", "B二沉"}, order = 77)
    @ColumnWidth(12)
    private BigDecimal totalCyanideSstB;

    // ======================== 从表字段（碱度指标各处理单元数据） ========================
    // 碱度 - 调节池
    @ExcelColumn(header = {"碱度", "调节池"}, order = 78)
    @ColumnWidth(12)
    private BigDecimal alkalinityRegulatingPool;

    // 碱度 - 一级好氧池A系
    @ExcelColumn(header = {"碱度", "一级好氧池", "A系"}, order = 79)
    @ColumnWidth(12)
    private BigDecimal alkalinityAerobicTankOneA;

    // 碱度 - 一级好氧池B系
    @ExcelColumn(header = {"碱度", "一级好氧池", "B系"}, order = 80)
    @ColumnWidth(12)
    private BigDecimal alkalinityAerobicTankOneB;

    // 碱度 - 二级好氧池A系
    @ExcelColumn(header = {"碱度", "二级好氧池", "A系"}, order = 81)
    @ColumnWidth(12)
    private BigDecimal alkalinityAerobicTankTwoA;

    // 碱度 - 二级好氧池B系
    @ExcelColumn(header = {"碱度", "二级好氧池", "B系"}, order = 82)
    @ColumnWidth(12)
    private BigDecimal alkalinityAerobicTankTwoB;

    // 最终出水 - COD
    @ExcelColumn(header = {"最终出水", "COD"}, order = 83)
    @ColumnWidth(12)
    private BigDecimal finalCOD;

    // 最终出水 - 氨氮
    @ExcelColumn(header = {"最终出水", "氨氮"}, order = 84)
    @ColumnWidth(12)
    private BigDecimal finalNh3n;

    // 最终出水 - PH
    @ExcelColumn(header = {"最终出水", "PH"}, order = 85)
    @ColumnWidth(12)
    private BigDecimal finalPH;

    // 最终出水 - 硫化物
    @ExcelColumn(header = {"最终出水", "硫化物"}, order = 86)
    @ColumnWidth(12)
    private BigDecimal finalSulfide;

    // 最终出水 - 挥发酚
    @ExcelColumn(header = {"最终出水", "挥发酚"}, order = 87)
    @ColumnWidth(12)
    private BigDecimal finalVolatilePhenols;

    // 最终出水 - 氰化物
    @ExcelColumn(header = {"最终出水", "氰化物"}, order = 88)
    @ColumnWidth(12)
    private BigDecimal finalCyanide;

    // 最终出水 - 总氮
    @ExcelColumn(header = {"最终出水", "总氮"}, order = 89)
    @ColumnWidth(12)
    private BigDecimal finalTN;

    // 最终出水 - 总磷
    @ExcelColumn(header = {"最终出水", "总磷"}, order = 90)
    @ColumnWidth(12)
    private BigDecimal finalTP;

    // 最终出水 - 多环芳烃
    @ExcelColumn(header = {"最终出水", "多环芳烃"}, order = 91)
    @ColumnWidth(12)
    private BigDecimal finalPAH;

    // 最终出水 - 苯并芘
    @ExcelColumn(header = {"最终出水", "苯并芘"}, order = 92)
    @ColumnWidth(12)
    private BigDecimal finalBaP;

    // 最终出水 - BOD
    @ExcelColumn(header = {"最终出水", "BOD"}, order = 93)
    @ColumnWidth(12)
    private BigDecimal finalBOD;

    // 最终出水 - 石油类
    @ExcelColumn(header = {"最终出水", "石油类"}, order = 94)
    @ColumnWidth(12)
    private BigDecimal finalPetroleum;

    // 最终出水 - 悬浮物
    @ExcelColumn(header = {"最终出水", "悬浮物"}, order = 95)
    @ColumnWidth(12)
    private BigDecimal finalSS;

    // 最终出水 - 苯
    @ExcelColumn(header = {"最终出水", "苯"}, order = 96)
    @ColumnWidth(12)
    private BigDecimal finalBenzene;

    // 最终出水 - 萘
    @ExcelColumn(header = {"最终出水", "萘"}, order = 97)
    @ColumnWidth(12)
    private BigDecimal finalNaphthalene;

    // 最终出水 - 色度
    @ExcelColumn(header = {"最终出水", "色度"}, order = 98)
    @ColumnWidth(12)
    private BigDecimal finalChroma;


    private BigDecimal parseBigDecimal(String value) {
        if (value == null || value.trim().isEmpty() || value.equals("-")) {
            return null;
        }
        try {
            return new BigDecimal(value.trim());
        } catch (NumberFormatException e) {
            // 记录日志或抛出异常，根据实际需求处理
            System.err.println("数值格式错误: " + value);
            return null;
        }
    }

}